window.addEventListener('load', function () {
    // 侧边广告模块
    // 点击关闭
    var close_btn = document.querySelector('.close-btn')
    var ad_float = document.querySelector('.ad-float');
    close_btn.addEventListener('click', function () {
        ad_float.style.display = 'none';
    })
    // 广告上下摆动
    var adY = ad_float.children[1].offsetTop;
    setInterval(function () {
        if (adY <= 10) {
            ad_float.children[1].style.transform = `translateY(${adY}px)`
        } else if (adY <= 20) {
            ad_float.children[1].style.transform = `translateY(${20 - adY}px)`
        } else {
            adY = 0;
        }
        adY++;
    }, 80)
    // 背景移动
    var index_bg = document.querySelector('.index-bg');
    var index_bg_cover = document.querySelector('.index-bg-cover');
    document.addEventListener('mousemove', function (e) {
        var x = document.querySelector('.header-bar').offsetWidth / 2;
        var y = 200;
        var moveX = e.pageX - x;
        var moveY = e.pageY - y;
        var bgmoveX = 10 * moveX / x;
        var bgmoveY = 3 * moveY / y;
        var bg_CmoveX = 20 * moveX / x;
        var bg_CmoveY = 6 * moveY / y;
        index_bg.style.transform = `translate(${-bgmoveX}px,${-bgmoveY}px)`
        index_bg_cover.style.transform = `translate(${-bg_CmoveX}px,${-bg_CmoveY}px)`
    })
})